//https://leetcode.cn/problems/count-and-say/

class Solution {
public:
    string countAndSay(int n) {
        string ret = "1";
        for (int i = 1; i < n; i++)
        {
            string temp;
            for (int left = 0, right = 0; right < ret.size();)
            {
                while (right < ret.size() && ret[left] == ret[right]) right++;
                temp += to_string(right - left) + ret[left];
                left = right;
            }
            ret = temp;
        }
        return  ret;
    }
};